﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Loggerz.Interfaces.User;
using System.Net;
using System.Security.Principal;
using System.Web;

namespace Loggerz.Classes.UserClass
{
    public class UserBase : IUserBase
    {
        private IPAddress _ipAddress;
        private string _dnsName;
        private WindowsIdentity _windowsUser;
        private string _customUserName;
        private string _applicationUserName;
        private bool _isAuthenticatedUser;
        private bool _isWindowsUser;
        private bool _isCustomUser;
        private bool _isWebApplication;
        private bool _isWindowsApplication;
        private HttpBrowserCapabilities _browserSettings; 

        public IPAddress IPAddress
        {
            get { return _ipAddress; }
        }

        public string DnsName
        {
            get { return _dnsName; }
        }

        public WindowsIdentity WindowsUser
        {
            get { return _windowsUser; }
        }

        public string CustomUserName
        {
            get { return _customUserName; }
        }

        public string ApplicationUserName
        {
            get { return _applicationUserName; }
        }

        public bool IsAuthenticatedUser
        {
            get { return _isAuthenticatedUser; }
        }

        public bool IsWindowsUser
        {
            get { return _isWindowsUser; }
        }

        public bool IsCustomUser
        {
            get { return _isCustomUser; }
        }


        public bool IsWebApplication
        {
            get { return _isWebApplication; }
        }

        public bool IsWindowsApplication
        {
            get { return _isWindowsApplication; }
        }

        public HttpBrowserCapabilities BrowserSettings
        {
            get { return _browserSettings; }
        }

        public UserBase(IPAddress ipaddress, string dnsName, WindowsIdentity windowsUser, string customUserName, string applicationUserName,
                            bool isAuthenticatedUser, bool isWindowsUser, bool isCustomUser, bool isWebApplication, bool isWindowsApplication,
                            HttpBrowserCapabilities browerSettings)
        {
            _ipAddress = ipaddress;
            _dnsName = dnsName;
            _windowsUser = windowsUser;
            _customUserName = customUserName;
            _applicationUserName = applicationUserName;
            _isAuthenticatedUser = isAuthenticatedUser;
            _isWindowsUser = isWindowsUser;
            _isCustomUser = isCustomUser;
            _isWebApplication = isWebApplication;
            _isWindowsApplication = isWindowsApplication;
            _browserSettings = browerSettings;
        }





        public IUserBase Clone()
        {
            IUserBase user = null;
            try
            {
                user = new UserBase(_ipAddress, _dnsName, _windowsUser, _customUserName, _applicationUserName, _isAuthenticatedUser,
                                    _isWindowsUser, _isCustomUser, _isWebApplication, _isWindowsApplication, _browserSettings);
            }
            catch (Exception error)
            {
                user = null;
                throw new InvalidOperationException("Can not clone this object", error);
            }

            return user;
        }
    }
}